﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Hanhud
{
    [Serializable()]
    public class CMenuItem
    {
        public int MenuItemID { get; protected set; }
        public int ParentMenuItemID { get; protected set; }
        private CMenuItem _parent = null;
        public CMenuItem Parent
        {
            get { return _parent; }
            protected set { _parent = value; }
        }
        public string ClientID { get; set; }
        public string Name { get; set; }
        public string Title { get; set; }
        public string ImageUrl { get; set; }
        public string RelativeUrl { get; set; }
        public int Priority { get; set; }

        private List<CMenuItem> _childMenuItems = new List<CMenuItem>();
        public List<CMenuItem> ChildMenuItems
        {
            get { return _childMenuItems; }
            protected set
            {
                _childMenuItems.Clear();
                _childMenuItems.AddRange(value);
            }
        }

        public CMenuItem()
            : this(-1)
        {
            this.ParentMenuItemID = -1;
        }

        public CMenuItem(int menuItemID)
        {
            this.MenuItemID = menuItemID;
            this.ParentMenuItemID = -1;
        }

        public CMenuItem(string clientID, string name, string title, string imageUrl, string relativeUrl, int priority)
            : this(-1)
        {
            this.ClientID = clientID;
            this.Name = name;
            this.Title = title;
            this.ImageUrl = imageUrl;
            this.RelativeUrl = relativeUrl;
            this.Priority = priority;
        }

        public CMenuItem(int menuItemID, int parentMenuItemID, string clientID, string name, string title, string imageUrl, string relativeUrl, int priority)
            : this(clientID, name, title, imageUrl, relativeUrl, priority)
        {
            this.MenuItemID = menuItemID;
            this.ParentMenuItemID = parentMenuItemID;
        }

        #region "Public override methods"
        public override bool Equals(object obj)
        {
            return this.MenuItemID == ((CMenuItem)obj).MenuItemID;
        }

        public override string ToString()
        {
            return base.ToString();
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        } 
        #endregion
    }
}